package main

import "fmt"

//定义一个结构体
type Account struct {
	AccountName string
	Pwd         string
	Balance     float64
}

//存款
func (acc *Account) Deposit(money float64, pwd string) {
	if pwd != acc.Pwd {
		fmt.Println("密码错误")
		return
	}
	acc.Balance += money
}

//取款
func (acc *Account) Withdrawal(money float64, pwd string) {
	if pwd != acc.Pwd {
		fmt.Println("密码错误")
		return
	}
	if money < 0 || money > acc.Balance {
		fmt.Println("账号余额不足")
		return
	}
	acc.Balance -= money
}

//查询余额
func (acc *Account) FindBalance(pwd string) {
	if pwd != acc.Pwd {
		fmt.Println("密码错误")
		return
	}
	fmt.Println("余额为=", acc.Balance)
}

func main() {
	account := &Account{
		AccountName: "majun",
		Pwd:         "111111",
		Balance:     23,
	}
	account.Deposit(100, "2323")
	account.Withdrawal(12212, "111111")
	account.FindBalance("111111")
}
